package dtos

import "github.com/edgexfoundry/edgex-go/internal/app/models"

type Product struct {
	Id               string `json:"id"`
	ProductName      string `json:"productName"`
	ProductIcon      string `json:"productIcon"`
	ProductOrganId   string `json:"productOrganId"`
	ProductOrganName string `json:"productOrganName"`
	TransportType    string `json:"transportType"`
	RuleChain        string `json:"ruleChain"`
	IsPublished      bool   `json:"published"`
	CreateTime       int64  `json:"createTime"`
	ProfileData      string `json:"profileData"`
	Description      string `json:"description"`
	ProvisionType    string `json:"provisionType"`
	RuleChainName    string `json:"ruleChainName"`
	TenantId         string `json:"tenantId"`
	DeviceNum        uint32 `json:"deviceNum"`
}

func ToProductModel(dto Product) models.Product {
	var p models.Product
	p.Id = dto.Id
	p.ProductName = dto.ProductName
	p.ProductIcon = dto.ProductIcon
	p.ProductOrganId = dto.ProductOrganId
	p.ProductOrganName = dto.ProductOrganName
	p.TransportType = dto.TransportType
	p.RuleChain = dto.RuleChain
	p.RuleChainName = dto.RuleChainName
	p.IsPublished = dto.IsPublished
	p.CreateTime = dto.CreateTime
	p.Description = dto.Description
	p.TenantId = dto.TenantId
	p.ProfileData = dto.ProfileData
	p.ProvisionType = dto.ProvisionType
	return p
}

func FromProductModelToDto(p models.Product) Product {
	var dto Product
	dto.Id = p.Id
	dto.ProductName = p.ProductName
	dto.ProductIcon = p.ProductIcon
	dto.ProductOrganId = p.ProductOrganId
	dto.ProductOrganName = p.ProductOrganName
	dto.TransportType = p.TransportType
	dto.RuleChain = p.RuleChain
	dto.RuleChainName = p.RuleChainName
	dto.IsPublished = p.IsPublished
	dto.CreateTime = p.CreateTime
	dto.Description = p.Description
	dto.TenantId = p.TenantId
	dto.ProfileData = p.ProfileData
	dto.ProvisionType = p.ProvisionType
	dto.DeviceNum = p.DeviceNum
	return dto
}
